package teacher;

import java.util.*;

public class Game {
    public static void main(String[] args) {
        Map<String,Integer> mapPrize = new HashMap<>();
        mapPrize.put("同花顺",100);
        mapPrize.put("四条",80);
        mapPrize.put("满堂红",60);
        mapPrize.put("同花",30);
        mapPrize.put("顺子",20);
        mapPrize.put("三条",5);
        mapPrize.put("两对",-10);
        mapPrize.put("一对",-20);
        mapPrize.put("杂牌",-30);

        Poker poker = new Poker();
        int score = 1000;
        Scanner scanner = new Scanner(System.in);
        while (score > 0){
            System.out.println("请下注");
            int bet = scanner.nextInt();
            scanner.nextLine();//吃掉换行符
            score -= bet;
            System.out.println("current score " + score);
            List<Card> hand = poker.getOneHand();
            System.out.println(hand);
            System.out.println(poker.getHandType(hand));
            System.out.println("请输入你想换的牌[1-5],用空格分割,回车什么也不换");
            //2 3 4
            String info = scanner.nextLine();
            if (!info.equals("")) {
                String[] arr = info.split(" ");
                for(int i = 0; i < arr.length; i++){
                    int no = Integer.parseInt(arr[i]);
                    no--;
                    Card card = poker.getOneCard(i+5);
                    hand.remove(no);
                    hand.add(no,card);
                }
            }
            System.out.println(hand);
            String type = poker.getHandType(hand);
            System.out.println(type);
            int prize = mapPrize.get(type);
            score += bet * prize;
            System.out.println("current score " + score);
        }

    }
}


